<!--20210304    zaq    创建vue文件-->
<!--20210511    zaq    设计界面以及数据格式-->

<template>
<!--发表说说-->
  <div class="insert_text" style="width: 80%">
<!--    表单-->
    <el-form ref="form" :model="form"
    >
<!--      <el-form-item label="说说分组">-->
<!--        <el-select v-model="form.gId" placeholder="请选择分组"-->
<!--        >-->
<!--          <el-option-->
<!--              v-for="group in groups"-->
<!--              :key="group.gID"-->
<!--              :label="group.gName"-->
<!--              :value="group.gName"></el-option>-->
<!--        </el-select>-->
<!--      </el-form-item>-->
      <el-form-item  label="身高(cm)：">
        <el-input
            type="number"
            v-model="form.height">
        </el-input>
      </el-form-item>
      <el-form-item  label="体重(kg)：">
        <el-input
            type="number"
            v-model="form.weight">
        </el-input>

      </el-form-item>
      <el-form-item label="胸围(cm)：">
        <el-input
            type="number"
            v-model="form.bust">
        </el-input>

      </el-form-item>
      <el-form-item label="腰围(cm)：">
        <el-input
            type="number"
            v-model="form.waist">
        </el-input>

      </el-form-item>
      <el-form-item  label="臀围(cm)：">
        <el-input
            type="number"
            v-model="form.hipline">
        </el-input>

      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-upload2" @click="submit" >发送</el-button>
      </el-form-item>

    </el-form>
  </div>
</template>

<script>
import {insert_16611} from "../../api";
import moment from "moment";

export default {
  name: "Text",
  methods:{
    submit(){
      const _this=this
      //合法性检验
      // if(_this.form.tText==null){
      //   _this.$message({
      //     type: 'error',
      //     message: '内容不能为空，请重新输入'
      //   });
      // }else{
        var uId=sessionStorage.getItem("uId")
        var gId=sessionStorage.getItem("gId")
        console.log("u:"+uId+"  g:"+gId)
        var body={
          uId:uId,
          gId:gId,
          height:_this.form.height,
          weight:_this.form.weight,
          bust:_this.form.bust,
          waist:_this.form.waist,
          hipline: _this.form.hipline,
          date:parseInt(
              moment(new Date()).format('yyyy-MM-DD')
          )
        }
        insert_16611(body).then(resp=>{
          if(resp.code>0){
            _this.$message({
              type: 'success',
              message: '发布说说成功'
            });
          }else{
            _this.$message({
              type: 'error',
              message: '发布说说失败:'+resp.note
            });
          }
        }).catch(err=>{
          _this.$message({
            type: 'error',
            message: '发布说说失败:'+err
          });
        })
      // }

    }
  },
  data(){
    return {
      form:{
        bId:-1,
        height:null,//身高
        weight:null,//体重
        bust:null,//胸围
        waist:null,//腰围
        hipline:null,//臀围
        date:null,//日期
        gId:'a',//分组
        uId:'',//用户ID
      },
      groups:[
        {
          gID:'1',
          gName:'a',
          gText:'aa',
          gBeginTime:'20210511',
          gEndTime:'',
          gDefault:'',
          uId:'',//用户ID
          tgId:'',//模板ID
          delete:'',//
        },
        {
          gID:'2',
          gName:'b',
          gText:'bb',
          gBeginTime:'20210511',
          gEndTime:'',
          gDefault:'',
          uId:'',//用户ID
          tgId:'',//模板ID
          delete:'',//
        }
      ]
    }
  }
}
</script>

<style scoped>
.insert_text{
  text-align: left;
}
</style>